package com.zc.basic.app.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zc.basic.domain.pojo.rpt.RptCommonBaseInfo;
import com.zc.basic.infra.service.CustomRptInfoService;
import com.zc.commons.pojo.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/cmnRpt")
public class CommonRptController {

    @Autowired
    private CustomRptInfoService rptInfoService;

    @PostMapping("/add")
    public ResponseData addRptInfo(@RequestBody RptCommonBaseInfo rptBaseInfo) {
        Integer code = 200;
        String message = "操作成功！";
        boolean save = rptInfoService.save(rptBaseInfo);
        if (!save) {
            code = 300;
            message = "操作失败！";
        }
        return new ResponseData(code, message);
    }


    @PostMapping(value = "/list")
    public Page<RptCommonBaseInfo> queryList(@RequestBody RptCommonBaseInfo rptBaseInfo, @RequestParam Integer pageNo, @RequestParam Integer pageSize) {
        QueryWrapper<RptCommonBaseInfo> queryWrapper = new QueryWrapper<>(rptBaseInfo);
        Page<RptCommonBaseInfo> page = new Page<>(pageNo, pageSize);
        Page<RptCommonBaseInfo> pageData = rptInfoService.page(page, queryWrapper);
        return pageData;
    }


}
